home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / events.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  2KB  |  71 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from __future__ import with_statement
  5. import wx
  6. import pprint
  7. import traceback
  8. import sys
  9. from threading import currentThread
  10. from weakref import ref
  11. MAINTHREAD_NAME = 'MainThread'
  12.  
  13. class ThreadsafeGUIProxy(object):
  14.     
  15.     def __init__(self, target):
  16.         self.target = target
  17.  
  18.     
  19.     def __getattr__(self, attr):
  20.         method = getattr(self.target, attr)
  21.  
  22.  
  23. from traceback import print_exc
  24.  
  25. def callevent(e):
  26.     e.ref = None
  27.     
  28.     try:
  29.         for callAfterCallback, a, k in e._callables:
  30.             
  31.             try:
  32.                 callAfterCallback(*a, **k)
  33.             continue
  34.             except Exception:
  35.                 e = None
  36.                 print_exc()
  37.                 continue
  38.             
  39.  
  40.     except AttributeError:
  41.         e.callable(*e.args, **e.kw)
  42.  
  43.  
  44. from wx import GetApp, NewEventType, PyEvent
  45.  
  46. def CallAfterCombining(callable, *args, **kw):
  47.     app = GetApp()
  48.     
  49.     try:
  50.         r = app._last
  51.     except AttributeError:
  52.         pass
  53.  
  54.     e = r()
  55.     if e is not None and e.ref is r:
  56.         return e._callables.append((callable, args, kw))
  57.     
  58.     
  59.     try:
  60.         evt = PyEvent(0, app._CallAfterId)
  61.     except AttributeError:
  62.         id = app._CallAfterId = NewEventType()
  63.         app.Connect(-1, -1, id, callevent)
  64.         evt = PyEvent(0, id)
  65.  
  66.     evt._callables = [
  67.         (callable, args, kw)]
  68.     evt.ref = app._last = ref(evt)
  69.     app.AddPendingEvent(evt)
  70.  
  71.